package cate.game.activity.warorder;

import cate.common.table.activity.warorder.row.WarorderBaseRow;
import cate.common.table.d.GDWarOrder;
import cate.game.activity.base.core.SubActivitySingle;
import cate.game.role.task.TaskGroup;
import easy.java.dev.note.NoteClass;

import java.util.List;

@NoteClass("战令任务数据")
public class RoleWarOrderTask extends SubActivitySingle<RoleWarOrder> {

	public void initialize(RoleWarOrder parent){
		super.initialize(parent);
	}


	@Override
	public void onEnter() {

	}

	public void excelCheck() {
		List<Integer> taskIds = role.getGame().table.warorder.task.getTaskIds(configGroup());
		role.getTask().getGroup(parent.funcId()).addItemListNoRepeat(taskIds, false);
	}

	public void beforeOver() {

	}

	public void clear() {
		parent.getRole().getTask().removeGroup(funcId());
	}

	public int configGroup() {
		WarorderBaseRow baseRow = parent.getRow();
		if (baseRow == null) {
			return -1;
		} else {
			return baseRow.taskGroup;
		}
	}

	@Override
	public void onDaySpan(boolean silence) {
		List<Integer> taskIds = role.getGame().table.warorder.task.getTaskIds(configGroup(), GDWarOrder.TaskType.DAILY);
		TaskGroup taskGroup = role.getTask().getGroup(funcId());
		taskGroup.removeItemList(taskIds);
		taskGroup.addItemListNoRepeat(taskIds, silence);
	}

	@Override
	public void onWeekSpan(boolean silence) {
		List<Integer> taskIds = role.getGame().table.warorder.task.getTaskIds(configGroup(), GDWarOrder.TaskType.WEEKLY);
		TaskGroup taskGroup = role.getTask().getGroup(funcId());
		taskGroup.removeItemList(taskIds);
		taskGroup.addItemListNoRepeat(taskIds, silence);
	}

//	public EcResult<MixRes> onGetTaskRwd(MixRes reward) {
//		int expNum = (int) reward.count(GDObj.Type.NUM, parent.getRow().expItemId);
//		if (expNum > 0) {
//			parent.level.addExp(expNum);
//			parent.level.noticeUpdate();
//		}
//		//除去经验的奖励
//		MixRes leftRwd = reward.copy();
//		leftRwd.items.removeIf(a -> a.type == GDObj.Type.NUM && a.tid == parent.getRow().expItemId);
//		if (!leftRwd.isEmpty()) {
//			new MixResAdder().setRes(leftRwd).exe(role);
//		}
//		return new EcResult<MixRes>().success("success", leftRwd);
//	}
}
